package com.wenwan.manage.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wenwan.manage.service.PhoneService;

import javax.annotation.Resource;

/**
 * 手机短信验证码
 * 
 * @author Admin
 *
 */
@Controller
@RequestMapping(value = "/phone")
public class PhoneAction {

	@Autowired
	private PhoneService phoneService;

	/**
	 * 发送手机验证码
	 * 
	 * @param phone
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/send/verification/code", method = { RequestMethod.POST })
	public Map<String, Object> sendVerificationCode(@RequestParam(required = true) String userId,
			@RequestParam(required = true) String phone, @RequestParam(required = true) String token) {
		return phoneService.sendVerificationCode(userId, phone, token);
	}

	/**
	 * 验证手机验证码
	 * 
	 * @param phone
	 * @param code
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/verification/phone", method = { RequestMethod.POST })
	public Map<String, Object> verificationPhone(@RequestParam(required = true) String userId,
			@RequestParam(required = true) String phone, @RequestParam(required = true) String code,
			@RequestParam(required = true) String token) {
		return phoneService.verificationPhone(userId, phone, code, token);
	}

	// @ResponseBody
	// @RequestMapping(value = "getVerificationCodeAsLogin", method = {
	// RequestMethod.POST })
	// public DataToObject<Boolean>
	// getVerificationCodeAsLogin(@RequestParam(required = true) String phone) {
	// DataToObject<Boolean> dto = phoneService.getVerificationCodeAsLogin(phone);
	// return dto;
	// }
	//
	// @ResponseBody
	// @RequestMapping(value = "verificationPhoneAsLogin", method = {
	// RequestMethod.POST })
	// public DataToObject<Boolean> verificationPhoneAsLogin(@RequestParam(required
	// = true) String phone,
	// @RequestParam(required = true) String code) {
	// DataToObject<Boolean> dto = phoneService.verificationPhoneAsLogin(phone,
	// code);
	// return dto;
	// }

}
